package com.ruoyi.service.impl;

import java.util.ArrayList;
import java.util.List;

import com.ruoyi.domain.T03;
import com.ruoyi.domain.T18;
import com.ruoyi.entity.VO.T09VO;
import com.ruoyi.mapper.T03Mapper;
import com.ruoyi.mapper.YYDT09Mapper;
import com.ruoyi.service.IT18Service;
import com.ruoyi.service.YYDIT09Service;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.domain.T09;


/**
 * 知识库Service业务层处理
 *
 * @author ruoyi
 * @date 2024-07-27
 */
@Service
public class YYDT09ServiceImpl implements YYDIT09Service
{
    @Autowired
    private YYDT09Mapper t09Mapper;
    @Autowired
    private T03Mapper t03Mapper;
    @Autowired
    private IT18Service t18Service;
    /**
     * 查询知识库
     *
     * @param F0901 知识库主键
     * @return 知识库
     */
    @Override
    public T09 selectT09ByF0901(Long F0901)
    {
        return t09Mapper.selectT09ByF0901(F0901);
    }

    /**
     * 查询知识库列表
     *
     * @param t09 知识库
     * @return 知识库
     */
    @Override
    public List<T09> selectT09List(T09 t09)
    {
        return t09Mapper.selectT09List(t09);
    }

    /**
     * 新增知识库
     *
     * @param t09 知识库
     * @return 结果
     */
    @Override
    public int insertT09(T09 t09)
    {
        return t09Mapper.insertT09(t09);
    }

    /**
     * 修改知识库
     *
     * @param t09 知识库
     * @return 结果
     */
    @Override
    public int updateT09(T09 t09)
    {
        return t09Mapper.updateT09(t09);
    }

    /**
     * 批量删除知识库
     *
     * @param F0901s 需要删除的知识库主键
     * @return 结果
     */
    @Override
    public int deleteT09ByF0901s(Long[] F0901s)
    {
        return t09Mapper.deleteT09ByF0901s(F0901s);
    }

    /**
     * 删除知识库信息
     *
     * @param F0901 知识库主键
     * @return 结果
     */
    @Override
    public int deleteT09ByF0901(Long F0901)
    {
        return t09Mapper.deleteT09ByF0901(F0901);
    }

    @Override
    public List<T09VO> selectT12V0List(T09 t09) {
        List<T09> t09S = t09Mapper.selectT09List(t09);
        List<T09VO> t09VOList=new ArrayList<>();
        List<Long> F0301s=new ArrayList<>();
        List<Long> F1801s=new ArrayList<>();
        if (!t09S.isEmpty()){
            for (T09 t09VO : t09S) {
                F0301s.add(t09VO.getF0301());
                F1801s.add(t09VO.getF1801());
            }
        }
        List<T03> t03s=new ArrayList<>();
        List<T18> t18s=new ArrayList<>();
        if(!F0301s.isEmpty()){
            t03s = t03Mapper.selectT03ListByF0301s(F0301s);
        }
        if (!F1801s.isEmpty()){
            t18s=t18Service.selectT18ListByF1801s(F1801s);
        }
        if (!t09S.isEmpty()){
            for (int i=0;i<t09S.size();i++) {
                T09VO t09VO1 = new T09VO();
                BeanUtils.copyProperties(t09S.get(i),t09VO1);
                t09VO1.setF0302(t03s.get(i).getF0302());
                t09VO1.setF1804(t18s.get(i).getF1804());
                t09VOList.add(t09VO1);
            }
        }
        return t09VOList;
    }
}
